package com.hxd.otc.module.order.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hxd.otc.R;
import com.hxd.otc.module.order.bean.AppealBean;
import com.hxd.otc.utils.ResourceUtil;
import com.hxd.otc.utils.UIUtils;

/**
 * 包  名 :  com.hxd.otc.module.order.adapter
 * 类  名 :  OllOrderAdapter
 * 作  者 :  zjl
 * 时  间 :  2018/6/5 18:03
 * 描  述 :  ${全部订单页面}
 */
public class ComplainListAdapter extends BaseQuickAdapter<AppealBean, BaseViewHolder> {


    String[] appleaType;

    public ComplainListAdapter() {
        super(R.layout.adapter_complain, null);
        appleaType = UIUtils.getContext().getResources().getStringArray(R.array.appeal_type_array);
    }

    @Override
    protected void convert(BaseViewHolder helper, final AppealBean item) {

        helper.setText(R.id.tv_number, UIUtils.getString(R.string.order_number, item.subOrderId));

        helper.setText(R.id.tv_decs_reson, item.reason);

        switch (item.status) {//状态1,申诉中2，处理完成，3撤销

            case 1:
                helper.getView(R.id.tv_statues).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (linster != null)
                            linster.onCancle(item.id);
                    }
                });
                helper.setText(R.id.tv_statues, ResourceUtil.getString(R.string.revocation_representation));
                if (appleaType.length >= item.appealType) {// 5 >= 2
                    helper.setText(R.id.tv_complain_reson, appleaType[item.appealType - 1]);
                }
                helper.setTextColor(R.id.tv_statues, UIUtils.getContext().getResources().getColor(R.color.color_FFFF7766));
                break;
            case 2:
                helper.setText(R.id.tv_statues, ResourceUtil.getString(R.string.order_completed));
                if (appleaType.length >= item.appealType) {
                    helper.setText(R.id.tv_complain_reson, appleaType[item.appealType - 1]);
                }
                helper.setTextColor(R.id.tv_statues, UIUtils.getContext().getResources().getColor(R.color.color_FF95A2AC));

                break;
            case 3:
                helper.setText(R.id.tv_statues, ResourceUtil.getString(R.string.cancel_appeal));
                if (appleaType.length >= item.appealType) {
                    helper.setText(R.id.tv_complain_reson, appleaType[item.appealType - 1]);
                }
                helper.setTextColor(R.id.tv_statues, UIUtils.getContext().getResources().getColor(R.color.color_FF95A2AC));
                break;
        }


    }

    OnClickCancleLinster linster;

    public void setLinster(OnClickCancleLinster linster) {
        this.linster = linster;
    }

    public interface OnClickCancleLinster {
        void onCancle(String id);
    }
}
